Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Save file details in my SQL database

$
0
0

I need to save details of a file from shared folder in my SQL DB. I have created a Model as: 

public partial class RsbfileDetail
    { public string FileUrl { get; set; }
        public string Filename { get; set; }
        public string CaseId { get; set; }
        public string FileType { get; set; }
        public int FileReferenceId { get; set; }
        public DateTime? CreatedDate { get; set; }
        public DateTime? UpdatedDate { get; set; }
        public string Status { get; set; }
        public string FileId { get; set; }
        public string Preset { get; set; }
        public string TranscodeCallbackUrl { get; set; }
        public string FileTranscodeJobId { get; set; }
        public string TranscriptionCallbackUrl { get; set; }
        public string JobDefinition { get; set; }
        public string TranscriptionJobId { get; set; }
    }

While taking from folder, I need to save the highlighted fields only.  Remaining things will be saved later as the code progresses. FileReferenceID is autogenerated and unique for every file. I wrote code in C# but it returns compile time errors in a service(different file). 

<div>

class FilePickerService    {        private static string path = string.Empty;        private static string authUrl = string.Empty;        private static string url = string.Empty;        private static string DownloadFileUri = string.Empty;        public FilePickerService(IConfiguration config)        {            path = config["FilePath:SharedFolderPath"];            authUrl = config["ApiUrls:authUrl"];            url = config["ApiUrls:url"];            DownloadFileUri = config["ApiUrls:DownloadFileUri"];        }        public async static void AiAuthenticate()        {            HttpClient client = new HttpClient();            string authPath = authUrl + "/oauth/token";            var parameters = new Dictionary<string, string> { { "username", "name" }, { "grant_type", "password" }, { "password", "password" } };            var encodedContent = new FormUrlEncodedContent(parameters);            var response = await client.PostAsync(authPath, encodedContent);            string result = response.Content.ReadAsStringAsync().Result;            var Bearer = result;            AddNewFileFromFolderToDB(client,Bearer);        }        public static void AddNewFileFromFolderToDB(HttpClient httpclient, string result)        {            HttpClient client = new HttpClient();            var Bearer = result;            using (var db = new rsbsrdbContext())            {                var file = new RsbfileDetail { FileReferenceId };                db.RsbfileDetails.Add(RsbfileDetail);                db.SaveChanges();            }        }
        }


</div>

This returns errors in the highlighted lines as:

FileReferenceID: can not initialize type "RSBfileDetail" with a collection initializer because it does not implement "System.Collections.IEnumerable".

FileReferenceID: The Name FileReferenceID does not exist in the current context.

RsbfileDetail: "RsbfileDetail" is a type, which is not valid in the current context.

How can I save the values into my Data Base fields? 
 


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>